<?php

declare(strict_types=1);

namespace App\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

class AdminPermissionRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        $id = $this->input('id');
        return [
            'name'             => 'bail|required|unique:admin_permissions,name,'  . $id,
            'remark'           => 'bail|required|unique:admin_permissions,remark,'  . $id,
            'type'              =>  'required'
        ];
    }

    public function messages(): array
    {
        return [
            'name.required'     =>  '权限名称必填',
            'name.unique'       =>  '权限名称已存在',

            'remark.required'     =>  '权限标示必填',
            'remark.unique'       =>  '权限标示已存在',

            'type'              =>  '权限类型必选'
        ];
    }
}
